import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 18128
 * Date: 2023-09-23
 * Time: 20:32
 */
class xuesheng implements Comparable<xuesheng>
{
    public int age;
    public String name;
    public xuesheng()
    {

    }
    public xuesheng(int age,String name)
    {
        this.age=age;
        this.name=name;
    }

    @Override
    public String toString() {
        return "姓名"+name+" "+"年龄"+age;
    }

    @Override
    public int compareTo(xuesheng o) {
        return this.age-o.age;
    }
}

public class qsqs {
    public static void hjxpai(Comparable[] xx)
    {
        for (int i = 0; i < xx.length-1; i++) {
            for (int j = 0; j < xx.length-1-i; j++) {
//                int cc=xx[j].compareTo(xx[j+1]);
//                System.out.println(cc);
                if(xx[j].compareTo(xx[j+1])>0)
                {
                    Comparable tmp=xx[j];
                    xx[j]=xx[j+1];
                    xx[j+1]=tmp;
                }
            }
        }
    }
    public static void main(String[] args) {
        xuesheng[] xx=new xuesheng[3];
        xx[0]=new xuesheng(10,"hxj");
        xx[1]=new xuesheng(16,"hkk");
        xx[2]=new xuesheng(13,"uuu");
        System.out.println(Arrays.toString(xx));
        hjxpai(xx);
        System.out.println(Arrays.toString(xx));

    }
}

